package com.iwdm.renovation;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import androidx.appcompat.app.AppCompatActivity;

public class StartActivity extends AppCompatActivity {

    //向主进程发送消息的句柄
    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            next();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        //延时3秒发送一个消息给主进程,让主进程执行next()方法
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(0);

            }
        }, 4000);
    }

    /**
     * 自定义方法
     * 启动登录界面
     */
    private void next() {
        startActivity(new Intent(this, LoginActivity.class));
        finish();
    }
}
